<?php
 /*******************************************************************************
 * @filename: search.ctp
 *
 * @author: immer_baldos
 *
 * @description: products/search view
 *
 * @history:
 *
 *   VERSION   DATE                   BY          NOTES
 *  ---------------------------------------------------------------
 *     1.0     September 20, 2009     immer       initial implementation
 *
 *     2.0     September 21, 2009     immer       add role based menus
 *
 ******************************************************************************/
 ?>
 <?php echo $form->create('Product',array('action'=>'search'));?>
    <fieldset>
	<?php
	    echo $form->input('select', array('label'=>'','options' => array("Id","Name","Description","Price")));
        echo $form->input('search', array('label'=>'','style'=>'position:relative;top:-60px;left:150px;width:50%'));
	    echo '<input type="submit" value="Search" style="position:relative;top:-60px;left:7px;"/></form>';
	?>
    </fieldset>

<div class="products index">
<h2><?php __('Products');?></h2>
<div class="actions">
	<ul>
		<li><?php echo $html->link(__('New Product', true), array('action' => 'add')); ?></li>
		<li><?php echo $html->link(__('List Products', true), array('action' => 'index')); ?></li>
		<li><?php
		        if ($_SESSION['Auth']['User']['role'] == "admin" ){
		            echo $html->link(__('List Transactions', true), array('controller' => 'transactions', 'action' => 'index'));
		        }
		    ?> </li>
		<li><?php
		        if ($_SESSION['Auth']['User']['role'] == "admin" ){
		            echo $html->link(__('New Transaction', true), array('controller' => 'transactions', 'action' => 'add'));
		        }
		    ?> </li>
	</ul>
</div>
<table cellpadding="0" cellspacing="0">
<tr>
	<th>id</th>
	<th>name</th>
	<th>description</th>
	<th>instock</th>
	<th>sold</th>
	<th>price</th>
	<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($products as $product):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td>
			<?php echo $product['products']['id']; ?>
		</td>
		<td>
			<?php echo $product['products']['name']; ?>
		</td>
		<td>
			<?php echo $product['products']['description']; ?>
		</td>
		<td>
			<?php echo $product['products']['instock']; ?>
		</td>
		<td>
			<?php echo $product['products']['sold']; ?>
		</td>
		<td>
			<?php echo $product['products']['price']; ?>
		</td>
		<td class="actions">
			<?php echo $html->link(__('View', true), array('action' => 'view', $product['products']['id'])); ?>
			<?php echo $html->link(__('Edit', true), array('action' => 'edit', $product['products']['id'])); ?>
			<?php echo $html->link(__('Delete', true), array('action' => 'delete', $product['products']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $product['products']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
</table>
</div>

